<template>
  <div class="music_list">
    <li class="list_head">
      <span>歌曲名</span>
      <span>专辑</span>
      <span>时长</span>
      <span></span>
    </li>
    <li class="list_content" v-for="(item, index) in list" :key="index">
      <span>{{ item.name }} </span>
      <span>{{ item.album }}</span>
      <span>{{ item.time }} </span>
      <span class="btn_box">
        <div class="play_btn">
          <div @click="toPlayPage(index)">
            <img src="../../assets/play.png" alt="" />
          </div>
        </div>
        <!-- <div class="collect_btn">
          <img src="../../assets/collect.png" alt="" />
        </div> -->
      </span>
    </li>
  </div>
</template>

<script>
export default {
  name: "music_list",
  props: {
    list: Array,
  },
  data(){
    return{
      newList:[],
    }
  },
  watch:{
    list: function(newData){
      this.newList = newData;
    }
  },
  mounted() {},
  methods: {
    toPlayPage(index) {
      this.$router.push({
        path: "/play_page",
        query: {
          songId: this.newList[index].id,//获取父组件数据的id
          flag:3,
          songCnt:this.$parent.reCnt,
          keyword:this.$parent.keyword,
        },
      });
    },
  },
};
</script>

<style scoped>
.music_list {
  width: 1192px;
  height: 650px;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0px 2px 5px 1px rgba(0, 0, 0, 0.15);
}
.music_list li {
  display: flex;
  justify-content: space-around;
  width: 1192px;
  height: 50px;
}

.music_list li:nth-child(1) span {
  font-weight: bold;
}

.music_list li span {
  width: 300px;
  text-align: center;
  line-height: 50px;
  font-family: Microsoft YaHei UI;
  color: #21262c;
  font-size: 18px;
  font-weight: 300;
}
.btn_box {
  display: flex;
  justify-content: flex-start;
}
.btn_box div {
  margin-right: 20px;
}
.btn_box img {
  width: 19px;
  height: 19px;
}
.music_list li:nth-child(even) {
  background-color: #efefef;
}
.play_btn > div:hover {
  cursor: pointer;
}
</style>